/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package org.biblio.persistencias;

import java.io.Serializable;
import java.util.List;
import javax.persistence.*;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;

/**
 *
 * @author Héctor <UFG>
 */
@Entity
@Table(name = "editorial", catalog = "mydb", schema = "")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "Editorial.findAll", query = "SELECT e FROM Editorial e"),
    @NamedQuery(name = "Editorial.findByEdiId", query = "SELECT e FROM Editorial e WHERE e.ediId = :ediId"),
    @NamedQuery(name = "Editorial.findByEdiNombre", query = "SELECT e FROM Editorial e WHERE e.ediNombre = :ediNombre"),
    @NamedQuery(name = "Editorial.findByEdiDireccion", query = "SELECT e FROM Editorial e WHERE e.ediDireccion = :ediDireccion"),
    @NamedQuery(name = "Editorial.findByEdiCorreo", query = "SELECT e FROM Editorial e WHERE e.ediCorreo = :ediCorreo"),
    @NamedQuery(name = "Editorial.findByEdiTelefono", query = "SELECT e FROM Editorial e WHERE e.ediTelefono = :ediTelefono"),
    @NamedQuery(name = "Editorial.findByEdiDescripcion", query = "SELECT e FROM Editorial e WHERE e.ediDescripcion = :ediDescripcion"),
    @NamedQuery(name = "Editorial.findByEdiEstado", query = "SELECT e FROM Editorial e WHERE e.ediEstado = :ediEstado")})
public class Editorial implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Column(name = "edi_id")
    private Integer ediId;
    @Basic(optional = false)
    @NotNull
    @Size(min = 1, max = 45)
    @Column(name = "edi_nombre", nullable = false, length = 45)
    private String ediNombre;
    @Size(max = 45)
    @Column(name = "edi_direccion", length = 45)
    private String ediDireccion;
    @Size(max = 45)
    @Column(name = "edi_correo", length = 45)
    private String ediCorreo;
    @Size(max = 8)
    @Column(name = "edi_telefono", length = 8)
    private String ediTelefono;
    @Basic(optional = false)
    @NotNull
    @Size(min = 1, max = 45)
    @Column(name = "edi_descripcion", nullable = false, length = 45)
    private String ediDescripcion;
    @Column(name = "edi_estado")
    private Boolean ediEstado;
    @JoinColumn(name = "edi_id_pais", referencedColumnName = "pais_id", nullable = false)
    @ManyToOne(optional = false)
    private Pais ediIdPais;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "libIdEdi")
    private List<Libro> libroList;

    public Editorial() {
    }

    public Editorial(Integer ediId) {
        this.ediId = ediId;
    }

    public Editorial(Integer ediId, String ediNombre, String ediDescripcion) {
        this.ediId = ediId;
        this.ediNombre = ediNombre;
        this.ediDescripcion = ediDescripcion;
    }

    public Integer getEdiId() {
        return ediId;
    }

    public void setEdiId(Integer ediId) {
        this.ediId = ediId;
    }

    public String getEdiNombre() {
        return ediNombre;
    }

    public void setEdiNombre(String ediNombre) {
        this.ediNombre = ediNombre;
    }

    public String getEdiDireccion() {
        return ediDireccion;
    }

    public void setEdiDireccion(String ediDireccion) {
        this.ediDireccion = ediDireccion;
    }

    public String getEdiCorreo() {
        return ediCorreo;
    }

    public void setEdiCorreo(String ediCorreo) {
        this.ediCorreo = ediCorreo;
    }

    public String getEdiTelefono() {
        return ediTelefono;
    }

    public void setEdiTelefono(String ediTelefono) {
        this.ediTelefono = ediTelefono;
    }

    public String getEdiDescripcion() {
        return ediDescripcion;
    }

    public void setEdiDescripcion(String ediDescripcion) {
        this.ediDescripcion = ediDescripcion;
    }

    public Boolean getEdiEstado() {
        return ediEstado;
    }

    public void setEdiEstado(Boolean ediEstado) {
        this.ediEstado = ediEstado;
    }

    public Pais getEdiIdPais() {
        return ediIdPais;
    }

    public void setEdiIdPais(Pais ediIdPais) {
        this.ediIdPais = ediIdPais;
    }

    @XmlTransient
    public List<Libro> getLibroList() {
        return libroList;
    }

    public void setLibroList(List<Libro> libroList) {
        this.libroList = libroList;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (ediId != null ? ediId.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Editorial)) {
            return false;
        }
        Editorial other = (Editorial) object;
        if ((this.ediId == null && other.ediId != null) || (this.ediId != null && !this.ediId.equals(other.ediId))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return ediNombre;
    }
    
}
